require 'net/https'
puts 'starting...'
def random_word
  alphabet = ('a'..'z').to_a
  (1..12).inject("") { |s,x| s << alphabet[rand(alphabet.size)]}
end

class GoogleAuth
  def self.login(email, password)
    http = Net::HTTP.new('www.google.com', 443)
    http.use_ssl = true
    path = '/accounts/ClientLogin'
    data = \
    "accountType=HOSTED&Email=#{email}" \
    "&Passwd=#{password}" \
    '&source=Galileoweb-labsignup-1.0'

    headers = \
    { 'Content-Type' => 'application/x-www-form-urlencoded'}

    http.post(path, data, headers)
  end
  
  def self.provoke_captcha(email)
    resp = nil
    data = nil
   
    while true do
      resp, data = GoogleAuth.login(email, random_word)
      puts resp	
      break if data.include?("Captcha")
    end
    [resp, data]
  end
end
GoogleAuth.provoke_captcha("peeperd4@galileoweb.org")
puts 'ending...'
